<template>
  <div>
    <index-cmpt :models="models"></index-cmpt>
    <submit-edit-dialog
      :visible.sync="submitVisible"
      @success="handleSubmitSuccess"
      :product-id="productId"
      @dismiss="handleClose"
    ></submit-edit-dialog>
  </div>
</template>

<script>
import IndexCmpt from '@/bank/views/business/28/normal/IndexCmpt'
import { mapGetters } from 'vuex'
import SubmitEditDialog from '@/bank/views/business/hplimit/submit/SubmitEditDialog'
export default {
  components: {
    SubmitEditDialog,
    IndexCmpt,
  },
  data() {
    return {
      submitVisible: false,
      refStatus: 1,
    }
  },
  computed: {
    ...mapGetters(['taskCounthpLimit', 'org', 'user']),
    productId() {
      return this.$route.query.id
    },
    models() {
      return [
        {
          title: '项目新增',
          subTitle: '待办',
          url: '/res_index/limit/hplimit/new',
          subCount: this.taskCounthpLimit.todo_send_total || 0,
          subUrl: 'task',
        },
        {
          title: '项目审批',
          subTitle: '待办',
          subCount: this.taskCounthpLimit.todo_approval_total || 0,
          subUrl: 'task',
          url: '/res_index/limit/hplimit/approve',
        },
        {
          title: '项目提交',
          subTitle: '待办',
          subCount: this.taskCounthpLimit.todo_submit_total || 0,
          subUrl: 'task',
          url: '/res_index/limit/hplimit/submit',
          onclick: this.showSubmitDiaog,
        },
        {
          title: '放款登记',
          subTitle: '待办',
          subCount: this.taskCounthpLimit.todo_register_total || 0,
          subUrl: 'task',
          url: '/res_index/limit/hplimit/register',
        },
        {
          title: '贷后管理',
          subTitle: '到期',
          subCount: this.taskCounthpLimit.todo_overdue_total || 0,
          subUrl: 'task',
          url: '/res_index/limit/hplimit/postloan',
        },
      ]
    },
  },
  created() {
    this.$store.dispatch('getTaskCounthpLimit')
  },
  methods: {
    showSubmitDiaog() {
      this.submitVisible = true
    },
    handleClose() {
      this.submitVisible = false
    },
    handleSubmitSuccess() {
      this.$router.push({
        path: '/res_index/limit/hplimit/submit',
        query: {
          id: this.productId,
          status: this.refStatus++,
        },
      })
    },
  },
}
</script>
<style lang="scss" scoped></style>
